from selenium import webdriver
from selenium.webdriver.chrome.options import Options

from Objects.loginPage import loginPage
from Util.Logger import Log


class LoginAction:

    def __init__(self):
        print('-----开始登录-----')
        self.log = Log()

    def login(self,wd,username,password):
        try:
            Login_page = loginPage(wd)
            # self.log.info('开始切换iframe')
            Login_page.switch_frame()
            # self.log.info('开始输入用户名')
            Login_page.input_username(username)
            # self.log.info('开始输入密码')
            Login_page.input_password(password)
            # self.log.info('点击登录按钮')
            Login_page.login_click()
        except Exception as e:
            print(e)
if __name__ == '__main__':
    chrome_Path = 'E:\RF\chromedriver.exe'
    options = Options()
    options.add_argument('--start-maximized')
    wd = webdriver.Chrome(executable_path=chrome_Path, options=options)
    wd.get('https://mail.163.com/')

    loginaction = LoginAction()
    loginaction.login(wd,'13037521553','Ruru970929.')